﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Reflection;
using MethodWorx.CMS.TemplateParser.Installer;

namespace MethodWorx.CMS.UI.Tests.Installer
{
    [TestClass]
    public class InstallerEngineTests
    {
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void EnsureStreamCanNotBeNull()
        {
            var insallerEngine = new InstallerEngine(null, null, null);
        }

        [TestMethod]
        public void TestReadZipFile()
        {
            using(var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MethodWorx.CMS.TemplateParser.Tests.terrafirma_mastertemplate.zip"))
            {
                var installerEngine = new InstallerEngine(null, stream, null);

                Assert.IsTrue(installerEngine.Files.Count() == 6);
                Assert.IsTrue(installerEngine.Files.Contains("a8.gif"));
                Assert.IsTrue(installerEngine.Files.Contains("a10.jpg"));
                Assert.IsTrue(installerEngine.Files.Contains("a50.gif"));
                Assert.IsTrue(installerEngine.Files.Contains("installer.xml"));
                Assert.IsTrue(installerEngine.Files.Contains("masterpagetemplate.xml"));
                Assert.IsTrue(installerEngine.Files.Contains("terrafirma.css"));
            }
        }
    }
}
